package top.whysu.edevice.controller.device;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import top.whysu.edevice.dto.device.RecordSensorQueryDTO;
import top.whysu.edevice.dto.generate.ResponseDTO;
import top.whysu.edevice.dto.page.PagenationDataDTO;
import top.whysu.edevice.po.device.RecordSensorPO;
import top.whysu.edevice.service.device.RecordSensorService;
import top.whysu.edevice.utils.ResponseUtil;

import javax.annotation.Resource;

/**
 * 信息列表（传感器数据）
 */
@Controller
@RequestMapping("/sensor")
public class SensorController {

    @Resource
    private RecordSensorService recordSensorService;

    @RequestMapping("/recordSensor")
    public String deviceManager() {
        return "device/recordSensor";
    }

    /**
     * 传感器上报记录列表
     */
    @RequestMapping("/getPage")
    @ResponseBody
    public ResponseDTO<PagenationDataDTO<RecordSensorPO>> getPage(@RequestBody RecordSensorQueryDTO queryDTO) {
        PagenationDataDTO<RecordSensorPO> page = recordSensorService.selectPage(queryDTO);
        return ResponseUtil.getSuccessResponse(page);
    }

}